package com.whitedust.top100;

import com.whitedust.structure.ListNode;

/**
 *
 * @author A
 * @since 2025/11/17 19:12
 */

public class Top91 {
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null) return null;
        ListNode dummy = new ListNode(head.val - 1, head);
        ListNode pre = dummy;
        while (head != null) {
            if (pre.val != head.val) {
                pre = pre.next;
                head = head.next;
            } else {
                pre.next = head.next;
                head = head.next;
            }
        }
        return dummy.next;
    }
}
